package com.swust.mapper;

import com.swust.po.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface UserMapper {
    @Select("select id uid,username from mybatis02.user where id = #{id}")
    @Results({
            @Result(column = "uid", property = "id")
    })
    public User findUserById(Integer id);

    @Select("SELECT id,username,birthday,gender,address FROM user WHERE id=${id}")
    @Results({
            @Result(column = "id", property = "id",id = true),
            @Result(column = "id", property = "orders",javaType = List.class,many = @Many(select = "com.swust.mapper.OrderMapper.findOrderAndUserLazy",fetchType = FetchType.LAZY))
    })
    List<User> findAlllazy();

}
